Technical Q&A TB53
Expanding the Set of Menu Item Modifier Keys


Q: How can I use Shift and Option keys with my menu Command keys?

A: First, consider that if your users need this many menu keys, it is often the case that some elements of your interface should be moved out of the menu bar and into some other part of your interface. But, assuming it can't be helped, here are three straightforward ways, in order of desirability (from Apple's perspective):

  • If SetMenuItemModifiers and MenuEvent are available, call them. (Or, instead of SetMenuItemModifiers, you can use 'xmnu' resources.)

  • Use a third-party MDEF and MenuKey replacement. One such package is called Mercutio. This is not an endorsement, and there may be other alternatives. (Drop us a note if you'd like your product listed here.)

  • Write your own MDEF and MenuKey replacement. If you choose to go with this option, here are some of the issues you'll need to address:

    • First, holding down the Option key changes the meaning of the key pressed. (For example, Option+8 = *, and Option+u is a dead key that prepares for an umlaut to be added to the following character.) These dead keys and "optional" characters differ between international versions of the system, and even move around the keyboard on various keyboards. It is also possible to install several script systems on the same Macintosh, so the Option key mappings could change frequently even within the same document. The KeyTranslate function will help you overcome this obstacle.

    • Second, make sure your MDEF is Appearance-savvy. It should call functions such as DrawThemeMenuItem and use the appropriate theme brushes such as kThemeTextColorMenuItemDisabled. The appropriate calls and brushes are documented in Mac OS 8 Toolbox Reference.

Further Reference:

Inside Macintosh: Menu Manager
Inside Macintosh: Appearance Manager
Inside Macintosh: Event Manager
Human Interface Guidelines
Mercutio

[Dec 22 1998]


Developer Documentation | Technical Notes | Development Kits | Sample Code